package Dahinh;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class ShapeTest {
	static ArrayList<TwoDimensionalShape> twoDArray;
	static ArrayList<ThreeDimensionalShape> threeDArray;
	static int r, d, h, k;
	static BufferedReader br;

	public ShapeTest() {
		Circle circle = new Circle(r);
		Square square = new Square(d);
		Triangle triangle = new Triangle(d, h);
		Sphere sphere = new Sphere(r);
		Cube cube = new Cube(d);
		Tetrahedron tetrahedron = new Tetrahedron(d);

		twoDArray = new ArrayList<>();
		threeDArray = new ArrayList<>();

		twoDArray.add(circle);
		twoDArray.add(square);
		twoDArray.add(triangle);

		threeDArray.add(sphere);
		threeDArray.add(cube);
		threeDArray.add(tetrahedron);

	}

	public static void main(String[] args) {
		ShapeTest st = new ShapeTest();
		br = new BufferedReader(new InputStreamReader(System.in));
		try {
			System.out
					.println("Nhap hinh ban muon tinh. \n 0. Circle \n 1. Square \n 2. Triangle \n 3. Sphere \n 4. Cube \n 5. Tetrahedron \n");
			k = Integer.parseInt(br.readLine());
			twoDArray.get(k).setDimension1(r);
			threeDArray.get(k-3).setDimension2(d);
			switch (k) {
			case 0:
				System.out.println("Nhap ban kinh: ");
				r = Integer.parseInt(br.readLine());
				twoDArray.get(k).setDimension1(r);
				System.out.println("Day la hinh " + twoDArray.get(k).getName());
				System.out.println("Dien tich la: "
						+ twoDArray.get(k).getArea());
				break;
			case 1:
				System.out.println("Nhap do dai canh: ");
				d = Integer.parseInt(br.readLine());
				twoDArray.get(k).setDimension1(d);
				System.out.println("Day la hinh " + twoDArray.get(k).getName());
				System.out.println("Dien tich la: "
						+ twoDArray.get(k).getArea());
				break;
			case 2:
				System.out.println("Nhap chieu rong: ");
				d = Integer.parseInt(br.readLine());
				System.out.println("Nhap chieu dai: ");
				h = Integer.parseInt(br.readLine());
				twoDArray.get(k).setDimension1(d);
				twoDArray.get(k).setDimension2(h);
				System.out.println("Day la hinh " + twoDArray.get(k).getName());
				System.out.println("Dien tich la: "
						+ twoDArray.get(k).getArea());
				break;
			case 3:
				System.out.println("Nhap ban kinh: ");
				r = Integer.parseInt(br.readLine());
				threeDArray.get(k-3).setDimension2(r);
				System.out.println("Day la hinh " + threeDArray.get(k-3).getName());
				System.out.println("Dien tich la: "
						+ threeDArray.get(k-3).getArea());
				break;
			case 4:
				System.out.println("Nhap do dai canh: ");
				d = Integer.parseInt(br.readLine());
				threeDArray.get(k-3).setDimension2(d);
				System.out.println("Day la hinh " + threeDArray.get(k-3).getName());
				System.out.println("Dien tich la: "
						+ threeDArray.get(k-3).getArea());
				break;
			case 5:
				System.out.println("Nhap do dai canh: ");
				d = Integer.parseInt(br.readLine());
				threeDArray.get(k-3).setDimension2(d);
				System.out.println("Day la hinh " + threeDArray.get(k-3).getName());
				System.out.println("Dien tich la: "
						+ threeDArray.get(k-3).getArea());
				break;
			default:
				break;
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}
